/*
 * @Author: zwf 240970521@qq.com
 * @Date: 2023-07-14 23:07:53
 * @LastEditors: zwf 240970521@qq.com
 * @LastEditTime: 2023-07-16 10:40:35
 * @FilePath: /esp32_cmake_test/pwm/inc/pwm.h
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#ifndef PWM_H
#define PWM_H

#include "driver/ledc.h"

typedef struct
{
    ledc_timer_t     timer;
    int              pin;
    ledc_mode_t      speedMode;
    int              freq;
    ledc_timer_bit_t dutyResolution;
} PwmCfg;

typedef struct PwmDev
{
    void *priv;
    esp_err_t (*setDuty)(struct PwmDev *, int);
    uint32_t (*getDuty)(struct PwmDev *);
} PwmDev;

void      PWM_delete(PwmDev *dev);
esp_err_t PWM_create(PwmCfg cfg, PwmDev **dev);

#endif
